#!/usr/bin/env node

const log = console.log;

let timer1,timer2,count=0;

log('timer1 starts...');

timer1 = setInterval(()=>{
  log('#1 is looping');
},500);

setTimeout(()=>{
  log('#1 game over!');
  clearInterval(timer1);
  log('timer2 starts...');
  timer2 = setInterval(loop2,500);
},5000);

function loop2(){
  count++;
  log('#2 is looping');
  if(count>5){
    log('#2 game over!');
    global.clearInterval(timer2);
  }
}

